package boot.spring.设计模式.原型;

public class Resume implements Cloneable {

    private String name;
    private String sex;
    private String age;
    private WorkExperience workExperience;

    public Resume(String name) {
        this.name = name;
        this.workExperience = new WorkExperience();
    }

    private Resume(WorkExperience workExperience) throws CloneNotSupportedException{
        // FIXME 深复制
        this.workExperience = (WorkExperience)workExperience.clone();
        // FIXME 浅复制 this.workExperience = workExperience;
    }

    public void setPersonInfo(String sex, String age){
        this.sex  = sex;
        this.age = age;
    }

    public void setWorkExperience(String workDate,String company){
        this.workExperience.setWorkDate(workDate);
        this.workExperience.setCompany(company);
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Resume resume = new Resume(this.workExperience);
        resume.age = this.age;
        resume.sex = this.sex;
        resume.name = this.name;
        return resume;
    }

    @Override
    public String toString() {
        return "Resume{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age='" + age + '\'' +
                ", workExperience=" + workExperience +
                '}';
    }
}
